<%--
    fileName      : /apptailor/cfsprodtail.jsp
    author        : user
    createDate    : 2017-03-17  
    lastModifier  : user
    lastModifyDate: 2017-03-17       
    description   : 列表页面
--%>
<%@ page language='java' contentType='text/html; charset=UTF-8' pageEncoding='UTF-8' %>
<%@ taglib uri='ctp-tag' prefix='ctp' %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
        <title></title>

        <ctp:include items='public,validator,groupbox,borderlayout,panel,form,button,toolbar,gridlayout,label,textfield,combobox,checkboxgroup,datepicker,grid,menus,chain,message_ex,link'/>

        <script type='text/javascript' kind='variant'>

            var borderlayout1;
            var querycondition;       //查询条件
            var queryForm;
            var queryGridlayout;
            var id; //主键
            var userid; //财富师id
            var term; //期限
            var amount; //金额
            var remark; //备注
            var time; //提交时间
            var reset;                //重置    
            var submit;               //提交
            var v_cfsprodtailId = "";		  //方法域中记录问题ID的变量
            var v_urlFirst='';
            var openFrom = '0';
            var queryGroupbox;
        </script>
        <script type='text/javascript' kind='event'>

	        /*
	         * @method addRecord
	         * @desc  新增信息
	         * @author user
	         */
 			function addRecord(){
     			window.location.href="<ctp:url href='cfsprodtailormain.flowc' flowActionName='cfsprodtaildetail'/>" + "&flag=0"
            }
            /*
	         * @method isChecked
	         * @desc  判断是否已选择数据
	         * @author user
	         */
           	function isChecked(){
           		v_cfsprodtailId = prolist.getSelectedRowId();
           		if(v_cfsprodtailId != null && v_cfsprodtailId != ""){
               		return true;
               	}else{
                   	return false;
                }
            }
           	/*
	         * @method modifyRecord
	         * @desc  修改信息
	         * @author user
	         */
            function modifyRecord(){
            	
                if(isChecked()){
                	var selects = prolist.getAllSelectedRowId();
                	if(selects.length > 1){
                		ctpMSB.alert({message:'<ctp:label key="mondify_one_record"/>',title:'<ctp:label key="tips_msg"/>',btn:[['确定','OK']],closeBtn:false});
                		return;
                    }
                	window.location.href="<ctp:url href='cfsprodtailormain.flowc' flowActionName='cfsprodtaildetail'/>" + "&flag=1"+"&id="+v_cfsprodtailId;
                }else{
                	ctpMSB.alert({message:'<ctp:label key="select_data"/>',title:'<ctp:label key="tips_msg"/>',btn:[['确定','OK']],closeBtn:false});
                }
            }
			/*
	         * @method delHandler
	         * @desc  删除Handler
	         * @author user
	         */
			function delHandler(tp){
				if(tp == "ok"){
					ctp.data.getJSONA({	
						url:'<ctp:url href="cfsprodtailormain.flowc" flowActionName="delcfsprodtail"/>',
						reqData : "id=" + v_cfsprodtailId,
						success :function(data){
									if(data && data[0].retCode =="0"){
										ctpMSB.alert({title :'<ctp:label key="delete_record"/>', message:'<ctp:label key="delete_succ"/>'});
										var url = '<ctp:url href="cfsprodtailormain.flowc" flowActionName="querycfsprodtail" />'+ '&fetchNum=36&begNum='+((prolist.footer.getCurPage()-1)*12+1)+getQueryInfo();;
										prolist.loadData(url);
									}							
									else {
										ctpMSB.alert({title:'<ctp:label key="delete_record"/>',message:'<ctp:label key="delete_fail"/>'});
									}
								}
					});
			 	}
			}
			/*
	         * @method deleteRecords
	         * @desc  删除信息
	         * @author user
	         */      
            function deleteRecords(){
                var confirmFlag = false;
                /*如果选择了数据，弹出确认删除对话框*/
                if(isChecked()){
        			ctpMSB.confirm({
        				title:'<ctp:label key="delete_record"/>',
        				message:'<ctp:label key="delete_continue"/>',
        				handler:delHandler
        			  });
                }else{
                	ctpMSB.alert({message:'<ctp:label key="delete_select"/>',title:'<ctp:label key="error_tips"/>',btn:[['确定','OK']],closeBtn:false});
                }
            }
            /*
	         * @method submitForm
	         * @desc  表单提交
	         * @author user
	         */ 
            function submitForm(){
            	var url='<ctp:url href="cfsprodtailormain.flowc" flowActionName="querycfsprodtail" params="language=\'zh_CN\';begNum=1;fetchNum=1;"/>'+getQueryInfo();
            	prolist.loadData(url);
            }
            /*
	         * @method resetForm
	         * @desc  表单重置
	         * @author user
	         */ 
            function resetForm(){
            	queryForm.reset();
            }

            /*
	         * @method getQueryInfo
	         * @desc  获取表单查询条件
	         * @author user
	         */ 
            function getQueryInfo(){
                var queryInfo ="&userid=" + encodeURI(userid.getValue())  					
					+"&tailorTimeStart=" + encodeURI(tailorTimeStart.getValue())  					
					+"&tailorTimeEnd=" + encodeURI(tailorTimeEnd.getValue())  										
					+"&custProp=" + encodeURI(custProp.getValue()) ;

                return queryInfo;
            }

            /*
	         * @method queryInfosExport
	         * @desc  查询结果导出
	         * @author user
	         */ 
            function queryInfosExport(){
            	var url='<ctp:url href="cfsprodtailormain.flowc" flowActionName="exporttailor" params="language=\'zh_CN\';begNum=1;fetchNum=999999;"/>'+getQueryInfo();
                window.location.href=url;
            }
            
        </script>
        <script type='text/javascript' kind='ui'>

            $(window).load(function(){
      		     //================================UI变量定义片段============================================================
					
						userid = new ctp.ui.textfield ({//财富师id
							id : 'userid' ,
							width:'180px',
							type : 'text'
						});	
					
						tailorTimeStart = new ctp.ui.datepicker ({//反馈时间 起始时间
							id : 'tailorTimeStart',value:'' ,width:'180px', isInput:true });
						
						tailorTimeEnd = new ctp.ui.datepicker ({//反馈时间 结束时间
						id : 'tailorTimeEnd',value:'' ,width:'180px', isInput:true });	
					
						custProp = new ctp.ui.combobox ({//处理状态(1.待处理  2.已答复)
						       id : 'custProp' ,
						       width:'180px',
						       defaultItems:[{
						            text:'---请选择---',
						            value:'',
						            selected:'true'
						           }],
						       items:[
						        {text:'个人',value:'0',title:'个人'},
						        {text:'机构',value:'1',title:'机构'}
						       ]
						      }); 
					
                 submit = new ctp.ui.button({//提交
                     id:'submit'
                 });

                 reset = new ctp.ui.button({//重置
                     id:'reset'
                 });

                 queryGridlayout = new ctp.ui.gridlayout({
                     id: 'queryGridlayout',
                     width: '850px',
                     align: 'center',
                     defaults:{
             			align: 'center',
             			label: {width: '100px'},
            			element:{
            				//默认创建textfield组件
            				type: 'textfield',
            				//默认的组件自带属性,width设成'100%'或不传，则该组件和关联标签的宽度之和会占满所在的列
            				options:{width: '120px'}
            			}
                         			
             		 },
                                  
                     items: [

      				[
						{
                                label: {
                                    id: 'label1', 
                                    text: '<ctp:label key="userid"/>', 
                                    width: '100px'
                                }, 
                                element: userid
                        }],
      				[{
					    label: {
					        id: 'label2', 
					        text: '订制时间', 
					        width: '100px'
					    }, 
					    element: tailorTimeStart
					},{
					
					label: {
					    id: 'labe3', 
					    text: '---', 
					    width: '150px'
					}, 
					element: tailorTimeEnd
					
					}],
					[
						{
                             label: {
                                 id: 'label4', 
                                 text: '客户性质', 
                                 width: '100px'
                             }, 
                             element: custProp
                     }]                        
                	                     ]
                 });
                 
                queryForm = new ctp.form({
                    id: 'queryForm',
                    items: [
						queryGridlayout
                    ],
                    postType:'ajax',
                    buttons : [{                           
	                        id: 'submit',              
	                        text: '<ctp:label key="submit"/>',                  
	                        icon:'apply',
	                        onClick: submitForm 
                 		}, {                                 
	                       id: 'reset',             
	                       text: '<ctp:label key="reset"/>',                   
	                       icon:'reload',
	                       onClick: resetForm
                 	    }]	
                });

                queryGroupbox = new ctp.ui.groupbox({
             		id:'queryGroupbox',
             		align :'center',
             		icon :'',
             		items:[queryForm]
                 });

                querycondition = new ctp.ui.panel({
                    id: 'querycondition',
                    contentPadding :'20px',
                    title: '<ctp:label key="query"/>',
                    items: [
						queryForm
                    ]
                });
                toolbar1 = new ctp.ui.toolbar({
                    id: 'toolbar1',
                    leftItems: [
                        {
                            type: 'button',
                            id: 'ExcelExport',
                            name: 'ExcelExport',
                            text: '<ctp:label key="export"/>',
                            icon: 'down',
                            onClick : queryInfosExport
                        }
                    ]
                });

                prolist = new ctp.ui.grid({
                    id: 'prolist',
                    title:'列表',
                    toolbar:toolbar1,
                    toolbarPos:'innertop',
                    header: {
                        title: [
                            [
                                {text: '',width: '80px'}
                                ,								
								{			
									text: '<ctp:label key="custprop"/>'
								},								
									{			
										text: '<ctp:label key="term"/>'
									},								
									{			
										text: '<ctp:label key="amount"/>'
									},								
									{			
										text: '<ctp:label key="remark"/>'
									},								
									{			
										text: '<ctp:label key="userid"/>'
									},
									{			
										text: '姓名'
									},
									{			
										text: '电话'
									},
									{			
										text: '业务部'
									},								
									{			
										text: '<ctp:label key="time"/>'
									}								                                
                            ]
                        ],
                        rowIdFieldName: "id",
                        attr: [
							{colType: 'radiobox'},
							{	
                            	fieldName: 'custprop',css:{"text-align":"center"}
								                            },
                            {	
	                            	fieldName: 'term',css:{"text-align":"center"}
									                            },
                            {	
	                            	fieldName: 'amount',css:{"text-align":"center"}
									                            },
                            {	
	                            	fieldName: 'remark',css:{"text-align":"center"}
									                            },
                            {	
                            		fieldName: 'userid',css:{"text-align":"center"}
								                            },
                            {	
                           		fieldName: 'username',css:{"text-align":"center"}
							                            },	
                            {	
                           		fieldName: 'mobile',css:{"text-align":"center"}
							                            },                            
                            {	
                           		fieldName: 'branchname',css:{"text-align":"center"}
							                            },	
								                            		                            
                            {	
	                            	fieldName: 'time',css:{"text-align":"center"}
									                            }  
                             		                                                                                 
                        ]
                    },
                    url:'<ctp:url href="cfsprodtailormain.flowc" flowActionName="querycfsprodtail" params="language=\'zh_CN\';begNum=1;fetchNum=1;"/>'
                    ,	
                    footer: {
						auto:true                    
                    }
                });

              
                borderlayout1 = new ctp.ui.borderlayout({
                    id:'borderlayout1',
                    type: '2E',
                    north__size: 0.3,
                    north__items:[querycondition],
                    center__items:[prolist],
                    north__closable:false,
                    north__resizable : true,
                    renderTo: 'body'
                });
            });
        </script>


    </head>
    <body>

        <ctp:form name="queryForm" method="post" action="cfsprodtailormain.flowc" flowActionName="">
        	
        </ctp:form>

    </body>
</html>
